<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../React/react.development.js"></script>
  <script src="../../React/react-dom.development.js"></script>
  <script src="../../React/babel.min.js"></script>
</head>

<body>
  <button id="btn">修改vDOM,并重新渲染</button>
  <div id="app"></div>
  <script type="text/babel">
    const arr = [{ id: '001', con: 'html' }, { id: '002', con: 'css' }, { id: '003', con: 'js' }]
    const vDom = (<ul>
      {
        arr.map(item => (<li key={item.id}>{item.con}<input type='text' /></li>))
      }
    </ul>)
    const re = ReactDOM.createRoot(document.getElementById('app'))
    re.render(vDom)
    let i = 0
    document.getElementById('btn').onclick = function () {
      arr.unshift({ id: Date.now(), con: "react" + i++ });
      re.render(
        <ul>
          {
            arr.map(item => (<li key={item.id}>{item.con} <input type="text" /></li>))
          }
        </ul>
      )
    }
  </script>
</body>

</html>